/**
 * \class WaitForResponse
 * \brief This class provides a ajax communication interface between server presenter layer and the view
 */

var sendRequest = new clientSideCommunicationInterface();
function WaitForResponse()
{
    if (sendRequest.requestComplete)
    {
        clearInterval('WaitForResponse()')
    }
    else
    {

}
}


function clientSideCommunicationInterface()
{
    this.serverURL = '/dazzler/ajaxhandler/';
    this.action= "none";
    this.parameters = {};
    this.dataToPost= {};
    this.returnData = null;
    this.requestComplete = false;
    this.setAction = function(actionString)
    {
        this.action = actionString;
    }

    this.setSendParameters = function(jsonParameters)
    {
        this.parameters=jsonParameters;
    }

    this.getResponse = function()
    {
        return this.returnData;
    }

    this.getSendData = function ()
    {
        return {
            'action':this.action,
            'parameters':this.parameters
            };
    }

    this.sentInfo = function ()
    {


        $.ajax({
            type: 'post',
            url: this.serverURL,
            data: {
                'action':this.action,
                'parameters':this.parameters
                },
            async: true,
            cache: false,
            success: function(data)
            {


                this.returnData = data;

            },
            error: function(XMLHttpRequest, textStatus, errorThrown){
                alert("error", textStatus + " (" + errorThrown + ")");
            }

        });
    }
}

